package com.esixnetwork.apollo.front.api;

import com.esixnetwork.apollo.common.head.Result;
import com.esixnetwork.apollo.front.vo.PackageSendRecord;
import com.esixnetwork.apollo.front.vo.TableData;
import com.esixnetwork.apollo.front.vo.sample;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * 接口层设计
 */
@Slf4j
@RestController
@RequestMapping("/api")
public class ApiController {

    /**
     * 测试方法记得删除
     */
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public Result add(){
        return Result.createBySuccess(new sample("1","2","3"));
    }

    @ApiOperation("退出登录")
    @RequestMapping(value = "/logout",method = RequestMethod.POST)
    public Result logout(HttpSession session){
        log.info("请求-退出登录");
        return Result.createBySuccessWithDefault();
    }

    @ApiOperation("发包器列表")
    @RequestMapping(value = "/getPackageSends",method = RequestMethod.GET)
    public Result getPackageSends(){
        log.info("请求-发包器列表");
        List<PackageSendRecord> pkList = new ArrayList<>();
        PackageSendRecord pk = new PackageSendRecord("广州1","127.0.0.1","广州IDC1");
        pkList.add(pk);
        pkList.add(pk);
        pkList.add(pk);
        pkList.add(pk);
        pkList.add(pk);
        TableData<PackageSendRecord> tableData = new TableData<>(10,1,pkList);
        return Result.createBySuccess(tableData);
    }

}
